home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d18
/
probots.arc
/
PATROL.PR
< prev
next >
Wrap
Text File
|
1991-04-28
|
2KB
|
83 lines
{
The Southern Patrol
Based on a C-Robot by Dave Chess
Strategy: run to the south border, and then run back and forth
along it, firing at anything that comes into range.
}
PROCEDURE Patrol;
VAR
course, scandir, Range : Integer;
PROCEDURE TURN;
BEGIN
{ Time to turn? }
IF ((loc_x < 200) AND (course = 180)) THEN drive(course, 0); {I.E.,Stop}
IF ((loc_x > 800) AND (course = 0)) THEN drive(course, 0); {I.E.,Stop}
{ Hit anything? }
IF (speed = 0) THEN
BEGIN
course := 180-course;
drive(course, 100);
END;
END; {Turn}
BEGIN {Main Patrol}
{ Go south, young 'droid! }
WHILE (loc_y > 5) DO
BEGIN
drive(270, 100);
WHILE (speed > 0) DO cannon(Random(359), 200);
END;
{ Set up for patrol }
IF (Random(1) = 0)
THEN course := 0
ELSE course := 180;
{ Patrol forever }
REPEAT
{ Time to turn? } TURN;
{ Look in various directions }
Range := scan(4, 4);
WHILE ((Range > 0) AND (Range < 700)) DO
BEGIN
cannon(0, Range);
Range := scan(4, 4);
{ Time to turn? } TURN;
END;
Range := scan(176, 4);
WHILE ((Range > 0) AND (Range < 700)) DO
BEGIN
cannon(180, Range);
Range := scan(176, 4);
{ Time to turn? } TURN;
END;
Range := scan(90, 10);
WHILE ((Range > 0) AND (Range < 700)) DO
BEGIN
cannon(85+Random(10), Range);
Range := scan(90, 10);
{ Time to turn? } TURN;
END;
scandir := Random(160)+10;
Range := scan(scandir, 10);
WHILE ((Range > 0) AND (Range < 700)) DO
BEGIN
cannon(scandir+Random(10)-5, Range);
Range := scan(scandir, 10);
{ Time to turn? } TURN;
END;
UNTIL Dead OR Winner; {REPEAT patrol-forever }
END; { End Patrol Main }